Get crime data from ArcGIS API and remove (4) entries with missing geometry; write cleaned data to GeoJSON

crime_dg <- st_read('https://utility.arcgis.com/usrsvcs/servers/3adad6320b7a421bb3826ec8871e2b66/rest/services/OpenData_PublicSafety/MapServer/2/query?outFields=*&where=1%3D1&f=geojson')
crime_dg <- dplyr::filter(crime_dg, !st_is_empty(crime_dg))
st_write(crime_dg, "data\crime_dg.geojson")

Read in data

crime_dg <- st_read("data//crime_dg.geojson")
## Reading layer `crime_dg' from data source 
##   `C:\Users\darkg\Desktop\Dropbox\Homework Scans\2024F_SDS625\HW3\data\crime_dg.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 709898 features and 12 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -72.71865 ymin: 41.72215 xmax: -72.64829 ymax: 41.80744
## Geodetic CRS:  WGS 84
parcel_dg <- st_read("data//parcel_hartford.geojson")
## Reading layer `parcel_hartford' from data source 
##   `C:\Users\darkg\Desktop\Dropbox\Homework Scans\2024F_SDS625\HW3\data\parcel_hartford.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 19143 features and 47 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -72.7182 ymin: 41.72368 xmax: -72.64208 ymax: 41.80743
## Geodetic CRS:  WGS 84

Census tracts from Tigris for map baselayer

hartford_tracts <- tracts(state = "CT", county = "Hartford", cb = TRUE) |> st_transform(crs = 4326)

plot

g = ggplot() +
   geom_sf(data = tracts(state = 09, year = 2023, filter_by = subset(county_subdivisions(state = 09), NAME == "Hartford"))) +
   theme_bw()

toWebGL(ggplotly(g))